
import unittest
import diabind
import testdata
import os

class LoadTest( unittest.TestCase ):

    def test_load_pdb(self):
        pdb_file_path = os.path.join(testdata.diabind_directory_path, "diabind.pdb")
        testdata.loaded_session = diabind.load_pdb(pdb_file_path)

        self.assertRaises( diabind.DiaError,
                           diabind.load_pdb,
                           pdb_file_path + "_not_found" )

        self.assertRaises( Exception, # All user-defined exceptions should also be derived from this class
                           diabind.load_pdb,
                           pdb_file_path + "_not_found_inheritance" )

    def test_load_exe(self):
        exe_file_path = os.path.join(testdata.diabind_directory_path, "diabind.pyd")
        testdata.loaded_session = diabind.load_exe(exe_file_path, testdata.diabind_directory_path)

        self.assertRaises( diabind.DiaError,
                           diabind.load_exe,
                           exe_file_path + "_not_found",
                           testdata.diabind_directory_path )

        self.assertRaises( Exception, # All user-defined exceptions should also be derived from this class
                           diabind.load_exe,
                           exe_file_path + "_not_found_inheritance",
                           testdata.diabind_directory_path )
